package cn.math.appmath.biz.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import cn.math.appmath.bean.DownloadBean;
import cn.math.appmath.biz.DownloadBiz;
import cn.math.appmath.dao.DownloadDao;
import cn.math.appmath.entity.Download;

public class DownloadBizImpl implements DownloadBiz {
	private DownloadDao downloadDao;
	
	public boolean delete(Integer[] ids) {
		return this.downloadDao.batchDelete(ids);
	}

	public DownloadBean findAll(int page, String param, int type) {
		if(param.equals("forward")){
			page = page - 2;
		}
		return downloadDao.findAll(page, type);
	}

	public boolean save(Download download) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 
		String time = sdf.format(new Date()); 
		download.setDcreateTime(time);
		return downloadDao.save(download);
	}

	public List<Download> findTop(){
		return downloadDao.findTop();
	}
	
	public void update(Download download) {
		// TODO Auto-generated method stub

	}

	public void setDownloadDao(DownloadDao downloadDao) {
		this.downloadDao = downloadDao;
	}
	
	public Download findById(Integer id) {
		return this.downloadDao.findById(id);
	}

}
